package framework.util.log
{
	import flash.display.Stage;
	import Global.GConfig;
	/**
	 * 日志系统
	 * 
	 * 
	 * 提供三种模式:
	 * 
	 *     static public const DEBUG_TRACE: int    = 01;                           在Output面板输出
		static public const DEBUG_REMOTE: int = 010;                         上报道服务端
		static public const DEBUG_ONLINE: int  = 0100;                       在客户端DebuggerUI内输出
	 * 
	 * 采用二进制操作:
	 * 
	 *             static public const DEBUG_MODE: int = DEBUG_TRACE | DEBUG_REMOTE | DEBUG_ONLINE;
	 *             表示采用三种方式记录信息
	 * 
	 * @author Henrylee{henrylee_sz@qq.com}
	 * 
	 * 
	 */
	public final class Logger
	{
		
		
		
		static private var instance: Logger;
		
		/** 主要是给在线调试模式提供一种解决方案 */
		static private var OnlineLog: OnlineLogger;
		
		public function Logger() 
		{
			trace("Debuger Mode::", GConfig.DEBUG_MODE);
		}
		
		
		public function init(stage:Stage):void
		{
			OnlineLog = new OnlineLogger();
			OnlineLog.init(stage);
		}
		
		
		
		static public function get logger(): Logger
		{
			if (instance == null)
			{
				instance = new Logger();
			}
			return instance;
		}
		
		
		static public function log(...arg):void
		{
			if (!GConfig.bDebug) return;
			
			if (GConfig.DEBUG_MODE & GConfig.DEBUG_TRACE)
			{
				trace(arg);
			}
			
			if (GConfig.DEBUG_MODE & GConfig.DEBUG_REMOTE)
			{
				//trace(arg);
			}
			
			if (GConfig.DEBUG_MODE & GConfig.DEBUG_ONLINE)
			{
				OnlineLog.log.apply(null, arg);
			}
		}
		
		
		
	}

}